var redis=require("redis");
var log=require("../utils/log");

var center_redis=null;
function connect_to_redis(host,port,db_index){
		center_redis=redis.createClient({
		host:host,
		port:port,
		db:db_index
	});

	center_redis.on("error",function(err){
		log.error(err);
	});
}

/*
function set_user_info_inredis(id,info){
	if (center_redis==null)
		return;

	var key="user_info_id_"+id;
	center_redis.hmset(key,info,function(err){
		if(err){
			log.error(err);
			return {err:1};
		}
	});
}

function get_user_info_inredis(id,call_back){
	if (center_redis==null)
		return;

	var key="user_info_id_"+id;
	center_redis.hgetall(key,function(err,data){
		if (err){
			call_back({err:1});
			return;
		}
		var result={
			nick:data.nick,
			sex:data.sex,
			face:data.face,
			vip:data.vip,
			is_guest:data.is_guest,
		};

		call_back({err:0,result});
		return;
	});
}
*/


module.exports={
	connect:connect_to_redis,
	//set_user_info_inredis:set_user_info_inredis,
	//get_user_info_inredis:get_user_info_inredis,
};